import time
from enum import Enum


class DateFormatEnum(Enum):
    middle_line = "yyyy-MM-dd"
    backslashes = "yyyy/MM/dd"
    no_symbol = "yyyyMMdd"


class DateUtils:

    @staticmethod
    def format_date(format_form: DateFormatEnum) -> str:
        """
        格式化时间
        :param format_form:枚举时间格式
        :return: 格式化后的时间
        """
        current_time = time.localtime()
        if not isinstance(format_form, DateFormatEnum):
            raise TypeError(f"{format_form}不是日期形式枚举类型")

        if format_form.value == DateFormatEnum.no_symbol.value:
            return f"{current_time.tm_year}{current_time.tm_mon}{current_time.tm_mday}"
        elif format_form.value == DateFormatEnum.middle_line.value:
            return f"{current_time.tm_year}-{current_time.tm_mon}-{current_time.tm_mday}"
        elif format_form.value == DateFormatEnum.backslashes.value:
            return f"{current_time.tm_year}/{current_time.tm_mon}/{current_time.tm_mday}"


if __name__ == "__main__":
    f = DateUtils.format_date(DateFormatEnum.backslashes)
    print(f)
